/**
 * Progetto PRAISED.
 * 24/gen/2011
 */
package it.uniroma3.dia.praised.core.dictionary;

import it.uniroma3.dia.praised.core.exception.DictionaryException;
import it.uniroma3.dia.praised.core.model.CandidateProteinName;
import it.uniroma3.dia.praised.core.model.InputText;
import it.uniroma3.dia.praised.core.model.ProteinName;

import java.io.IOException;
import java.util.List;
import java.util.concurrent.ExecutionException;

/**
 * @author Accosta Augusto
 * @author Lopez Elisabetta
 *
 */
public class Dictionary {

	private List<ProteinName> proteinList;
	private ExclusionModule exclusion;
	private RepositoryChecker checker;
	
	/**
	 * 
	 */
	public Dictionary(List<ProteinName> proteinList) {
		this.proteinList = proteinList;
		this.exclusion = new ExclusionModule();
		this.checker = new RepositoryChecker();
	}

	public List<CandidateProteinName> discoverProtein(InputText inputText) throws DictionaryException {
		List<CandidateProteinName> candidateList; 
		try {
			this.exclusion.excludeTokenFromInput(inputText);
			candidateList = this.checker.extractCandidates(inputText, this.proteinList);
			
			System.out.println("NUMBER OF CANDIDATES " + candidateList.size());
		} catch (IOException e) {
			throw new DictionaryException(e);
		} catch (InterruptedException e) {
			throw new DictionaryException(e);
		} catch (ExecutionException e) {
			throw new DictionaryException(e);
		}
		
		return candidateList;
	}
	
}
